#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
  printf("I am a process! pid:%d\n",getpid());
  
  //char* str=(char*)"MYVAL=bbbbbbbbbbbbbbbbbbb";
  //putenv(str);
  
  char* const env[]={(char*)"SHUJU=zbw",(char*)"WZ=fujian",NULL};
  pid_t id=fork();
  //putenv("str");
  if(id==0)
  {
    //child process
    //putenv(str);
    printf("exec begin ... \n");
    //execl("./test","test",NULL);
    execle("./test","test",NULL,env);
    printf("exec end ... \n");
    exit(1);
  }
  //father process
  int status=0;
  pid_t rid=waitpid(id,&status,0);
  if(rid>0)
  {
    if(WIFEXITED(status))
    {
      printf("wait success!rid:%d exit_code:%d\n",rid,WEXITSTATUS(status));
    }
  }
  return 0;
}
